import request from "@/utils/request"
const BASE_URL = process.env.VUE_APP_BASE_URL_BI

/**
 * 合同数量分析/金额分析/回款金额分析
 * count：合同数量分析；money：金额分析；back：回款金额分析
 */
export function biAchievementAnalysisAPI(data) {
	const type = data.tableType
	if (!type) return Promise.reject()
	delete data.tableType
	const url = {
		count: BASE_URL + "biEmployee/contractNumStats",
		money: BASE_URL + "biEmployee/contractMoneyStats",
		back: BASE_URL + "biEmployee/receivablesMoneyStats"
	}[type]
	if (!url) return Promise.reject()
	return request({
		url,
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

export function biAchievementAnalysisExportAPI(data) {
	const type = data.tableType
	if (!type) return Promise.reject()
	delete data.tableType
	const url = {
		count: BASE_URL + "biEmployee/contractNumStatsExport",
		money: BASE_URL + "biEmployee/contractMoneyStatsExport",
		back: BASE_URL + "biEmployee/receivablesMoneyStatsExport"
	}[type]
	if (!url) return Promise.reject()
	return request({
		url,
		method: "post",
		data: data,
		responseType: "blob",
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 合同汇总表
 * @param {*} data
 */
export function biAchievementSummaryAPI(data) {
	return request({
		url: BASE_URL + "biEmployee/totalContract",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

export function biAchievementSummaryExportAPI(data) {
	return request({
		url: BASE_URL + "biEmployee/totalContractExport",
		method: "post",
		data: data,
		responseType: "blob",
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 发票统计分析
 * @param {*} data
 */
export function biAchievementInvoiceAPI(data) {
	return request({
		url: BASE_URL + "biEmployee/invoiceStats",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 发票统计分析导出
 * @param {*} data
 */
export function biAchievementInvoiceExportAPI(data) {
	return request({
		url: BASE_URL + "biEmployee/invoiceStatsExport",
		method: "post",
		data: data,
		responseType: "blob",
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 发票详情列表
 * @param {*} data
 */
export function biInvoiceDetailListAPI(data) {
	return request({
		url: BASE_URL + "crmBiSearch/searchInvoicePageList",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 回款详情列表
 * @param {*} data
 */
export function biReceivablesDetailListAPI(data) {
	return request({
		url: BASE_URL + "crmBiSearch/searchReceivablesPageList",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 金额比例明细表
 * @param {*} data
 */
export function biEmployeeMoneyRatioDetailAPI(data) {
	return request({
		url: BASE_URL + "biEmployee/moneyRatioDetail",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 金额比例明细导出
 * @param {*} data
 */
export function biEmployeeMoneyRatioDetailExportAPI(data) {
	return request({
		url: BASE_URL + "biEmployee/moneyRatioDetailExport",
		method: "post",
		data: data,
		responseType: "blob",
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 金额比例汇总表
 * @param {*} data
 */
export function biEmployeeMoneyRatioTotalAPI(data) {
	return request({
		url: BASE_URL + "biEmployee/moneyRatioTotal",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 金额比例汇总导出
 * @param {*} data
 */
export function biEmployeeMoneyRatioTotalExportAPI(data) {
	return request({
		url: BASE_URL + "biEmployee/moneyRatioTotalExport",
		method: "post",
		data: data,
		responseType: "blob",
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}
